//
//  TopListView.m
//  iMine
//
//  Created by gaoxiang on 09-3-30.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "TopListView.h"
#import "PlayerScoreInfo.h"

@implementation TopListView

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code here.
    }
    return self;
}


- (void)setScoreInfos:(NSArray *)infos
{
	scoreInfos = infos;
	if ([infos count] > 0)
	{
		[playerNameLabel1 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:0] playerName]];
		[secondLabel1 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:0] elapsedTime]]];
	}
	else
	{
		[playerNameLabel1 setStringValue:@"Nobody"];
		[secondLabel1 setIntValue:999];
	}
	if ([infos count] > 1)
	{
		[playerNameLabel2 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:1] playerName]];
		[secondLabel2 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:1] elapsedTime]]];
	}
	else
	{
		[playerNameLabel2 setStringValue:@"Nobody"];
		[secondLabel2 setIntValue:999];
	}
	if ([infos count] > 2)
	{
		[playerNameLabel3 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:2] playerName]];
		[secondLabel3 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:2] elapsedTime]]];
	}
	else
	{
		[playerNameLabel3 setStringValue:@"Nobody"];
		[secondLabel3 setIntValue:999];
	}
	if ([infos count] > 3)
	{
		[playerNameLabel4 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:3] playerName]];
		[secondLabel4 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:3] elapsedTime]]];
	}
	else
	{
		[playerNameLabel4 setStringValue:@"Nobody"];
		[secondLabel4 setIntValue:999];
	}
	if ([infos count] > 4)
	{
		[playerNameLabel5 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:4] playerName]];
		[secondLabel5 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:4] elapsedTime]]];
	}
	else
	{
		[playerNameLabel5 setStringValue:@"Nobody"];
		[secondLabel5 setIntValue:999];
	}
	if ([infos count] > 5)
	{
		[playerNameLabel6 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:5] playerName]];
		[secondLabel6 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:5] elapsedTime]]];
	}
	else
	{
		[playerNameLabel6 setStringValue:@"Nobody"];
		[secondLabel6 setIntValue:999];
	}
	if ([infos count] > 6)
	{
		[playerNameLabel7 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:6] playerName]];
		[secondLabel7 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:6] elapsedTime]]];
	}
	else
	{
		[playerNameLabel7 setStringValue:@"Nobody"];
		[secondLabel7 setIntValue:999];
	}
	if ([infos count] > 7)
	{
		[playerNameLabel8 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:7] playerName]];
		[secondLabel8 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:7] elapsedTime]]];
	}
	else
	{
		[playerNameLabel8 setStringValue:@"Nobody"];
		[secondLabel8 setIntValue:999];
	}
	if ([infos count] > 8)
	{
		[playerNameLabel9 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:8] playerName]];
		[secondLabel9 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:8] elapsedTime]]];
	}
	else
	{
		[playerNameLabel9 setStringValue:@"Nobody"];
		[secondLabel9 setIntValue:999];
	}
	if ([infos count] > 9)
	{
		[playerNameLabel10 setStringValue:[(PlayerScoreInfo *)[infos objectAtIndex:9] playerName]];
		[secondLabel10 setStringValue:[NSString stringWithFormat:@"%d", [(PlayerScoreInfo *)[infos objectAtIndex:9] elapsedTime]]];
	}
	else
	{
		[playerNameLabel10 setStringValue:@"Nobody"];
		[secondLabel10 setIntValue:999];
	}
}

- (void)drawRect:(NSRect)rect {
    // Drawing code here.
}

@end
